package com.thug.tools;

import static org.junit.Assert.assertEquals;

import org.jbehave.core.annotations.AfterScenario;
import org.jbehave.core.annotations.BeforeScenario;
import org.jbehave.core.annotations.Given;
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.jbehave.core.annotations.When;

import com.thug.bo.Customer;
import com.thug.bo.Shop;
import com.thug.bo.Shop.State;

public class ShopSteps {

	private Shop shop;
	private Customer customer;

	public ShopSteps(Shop shop) {
		super();
		this.shop = shop;
	}

	@Given("the shop is opened")
	public void newShop() {
		shop.open();
	}

	@When("customer $firstName $lastName enters the shop")
	public void customerEntersTheShop(@Named("firstName") String firstName, @Named("lastName") String lastName) {
		customer = new Customer(firstName, lastName);
		System.out.println(firstName + " " + lastName + " enters the shop.");
	}

	@When("the customer asks for a punching ball")
	public void askPunchingBall() {
		customer.askPunchingBall(shop);
	}

	@Given("the shop does not have any punching ball")
	public void doesNotHavePunchingBall() {
		shop.setHasPunchingBalls(false);
	}

	@Then("shop is destroyed")
	public void shopIsDestroyed() {
		assertEquals(State.DESTROYED, shop.getState());
	}

	@Then("shop is open")
	public void shopIsOpen() {
		assertEquals(State.OPEN, shop.getState());
	}

	@BeforeScenario
	@AfterScenario
	public void printBlankLine() {
		System.out.println("");
	}
}
